03 / 06

What is cold start, and how can you mitigate it?

A cold start occurs when AWS Lambda initializes a new execution environment in response to an invocation, which adds latency before the function begins execution. This typically happens when a function is invoked after a period of inactivity or when scaling to handle concurrent requests. Cold starts are more noticeable in VPC-connected functions and interpreted languages like Python and Node.js.

Causes of Cold Starts
  1. 1

    First-time invocation after deployment or inactivity

  2. 2

    Scaling to new concurrent executions beyond warm environments

  3. 3

    Using VPCs without properly configured networking

  4. 4

    Large dependencies that slow down initialization

Strategies to Mitigate Cold Starts
  1. 1

    Use provisioned concurrency to keep instances warm

  2. 2

    Minimize the size of your deployment package

  3. 3

    Avoid unnecessary VPC usage or use efficient VPC configurations

  4. 4

    Use lighter runtimes like Go or Node.js for faster start-up

  5. 5

    Keep initialization code outside the handler function

Enable Provisioned Concurrency Using CLI